/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityprojet;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author T.Ron
 */
@Entity
@Table(name = "COMPTEA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Comptea.findAll", query = "SELECT c FROM Comptea c"),
    @NamedQuery(name = "Comptea.findByIdCa", query = "SELECT c FROM Comptea c WHERE c.idCa = :idCa"),
    @NamedQuery(name = "Comptea.findByTypeca", query = "SELECT c FROM Comptea c WHERE c.typeca = :typeca"),
    @NamedQuery(name = "Comptea.findByNumca", query = "SELECT c FROM Comptea c WHERE c.numca = :numca"),
    @NamedQuery(name = "Comptea.findByIntituleca", query = "SELECT c FROM Comptea c WHERE c.intituleca = :intituleca")})
public class Comptea implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_CA")
    private Integer idCa;
    @Basic(optional = false)
    @Column(name = "TYPECA")
    private short typeca;
    @Basic(optional = false)
    @Column(name = "NUMCA")
    private String numca;
    @Basic(optional = false)
    @Column(name = "INTITULECA")
    private String intituleca;
    @JoinTable(name = "COMPTEAG", joinColumns = {
        @JoinColumn(name = "ID_CA", referencedColumnName = "ID_CA")}, inverseJoinColumns = {
        @JoinColumn(name = "ID_CG", referencedColumnName = "ID_CG")})
    @ManyToMany
    private Collection<Compteg> comptegCollection;
    @JoinColumn(name = "SA", referencedColumnName = "SA")
    @ManyToOne(optional = false)
    private Sectionanal sa;
    @JoinColumn(name = "NA", referencedColumnName = "NA")
    @ManyToOne
    private Niveauanalyse na;

    public Comptea() {
    }

    public Comptea(Integer idCa) {
        this.idCa = idCa;
    }

    public Comptea(Integer idCa, short typeca, String numca, String intituleca,Sectionanal sa) {
        this.idCa = idCa;
        this.typeca = typeca;
        this.numca = numca;
        this.intituleca = intituleca;
        this.sa=sa;
    }

    public Integer getIdCa() {
        return idCa;
    }

    public void setIdCa(Integer idCa) {
        this.idCa = idCa;
    }

    public short getTypeca() {
        return typeca;
    }

    public void setTypeca(short typeca) {
        this.typeca = typeca;
    }

    public String getNumca() {
        return numca;
    }

    public void setNumca(String numca) {
        this.numca = numca;
    }

    public String getIntituleca() {
        return intituleca;
    }

    public void setIntituleca(String intituleca) {
        this.intituleca = intituleca;
    }

    @XmlTransient
    public Collection<Compteg> getComptegCollection() {
        return comptegCollection;
    }

    public void setComptegCollection(Collection<Compteg> comptegCollection) {
        this.comptegCollection = comptegCollection;
    }

    public Sectionanal getSa() {
        return sa;
    }

    public void setSa(Sectionanal sa) {
        this.sa = sa;
    }

    public Niveauanalyse getNa() {
        return na;
    }

    public void setNa(Niveauanalyse na) {
        this.na = na;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCa != null ? idCa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Comptea)) {
            return false;
        }
        Comptea other = (Comptea) object;
        if ((this.idCa == null && other.idCa != null) || (this.idCa != null && !this.idCa.equals(other.idCa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityprojet.Comptea[ idCa=" + idCa + " ]";
    }
    
}
